package com.genius.smsdao.actionmanage.domain;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.genius.smsbase.Domain.BaseEntity;
import com.genius.smsdao.studentmanage.domain.Student;

import javax.persistence.*;
import java.util.List;

/**
 * @Entity:Action 二课活动实体类
 * 对应数据库表名：action
 * @author：
 */
@Entity
@Table(name = "action")
public class Action extends BaseEntity<Long> {

    @Column
    private String name;
    @Column
    private String description;//描述
    @Column
    private Double point;//点数

    //二课活动到二课多对一关系
    @JsonIgnoreProperties("actionList")
    @ManyToOne(targetEntity = ActionKind.class,fetch = FetchType.EAGER)
    @JoinColumn(name = "action_kind_id",referencedColumnName = "id")
    private ActionKind actionKind;

    //二课活动到学生多对多关系，二课被选
    @JsonIgnoreProperties(value = "actionList",allowSetters = true)
    @ManyToMany(mappedBy = "actionList")
    private List<Student> studentList;


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Double getPoint() {
        return point;
    }

    public void setPoint(Double point) {
        this.point = point;
    }

    public ActionKind getActionKind() {
        return actionKind;
    }

    public void setActionKind(ActionKind actionKind) {
        this.actionKind = actionKind;
    }

    public List<Student> getStudentList() {
        return studentList;
    }

    public void setStudentList(List<Student> studentList) {
        this.studentList = studentList;
    }

    @Override
    public String toString() {
        return "Action{" +
                "name='" + name + '\'' +
                ", description='" + description + '\'' +
                ", point=" + point +
                ", actionKind=" + actionKind +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                ", id=" + id +
                '}';
    }
}
